package org.wannatrak.android.helper;

import android.util.Log;
import org.wannatrak.android.ApplicationContext;

/**
 * @Author: Maksim Tulupov maxtulupov@gmail.com
 * @Date: $Date: 2011-06-14 13:32:03 +0000 (Tue, 14 Jun 2011) $ 9:38 AM
 * @version: $Revision: 2 $
 * @id: $Id: WannatrakHelper.java 2 2011-06-14 13:32:03Z maxtulupov@gmail.com $
 */
public class WannatrakHelper {

    public static long convertStringIntervalInMillis(String interval) {
        int hours = 0;
        int minutes = 0;
        if (interval != null) {
            String[] split = interval.split(":");
            if (split.length == 2) {
                try {
                    hours = Integer.valueOf(split[0]);
                    minutes = Integer.valueOf(split[1]);
                } catch (NumberFormatException e) {
                    Log.e(WannatrakHelper.class.getSimpleName(), "convert string error", e);
                }
            }
        }
        return hours * 60 * 60 * 1000L + minutes * 60 * 1000L;
    }

    public static long convertStringIntervalInMinutes(String interval) {
        return convertStringIntervalInSeconds(interval) / 60L;
    }

    public static long convertStringIntervalInSeconds(String interval) {
        return convertStringIntervalInMillis(interval) / 1000L;
    }
}
